#include <iostream>
#include <fstream>
#include <string>
#include "head.hpp"
using namespace std;

int main()
{
    // utf16le_to_utf8bom("../utf16-le.txt","../outpath/utf16le-utf8bom.txt");

    // ifstream ifs("../gb2312.txt", ios::in | ios::binary);
    // ofstream ofs("../outpath/gb2312_utf8.txt", ios::out | ios::binary);

    ifstream ifs("../utf-8.txt", ios::in | ios::binary);
    ofstream ofs("../outpath/utf8_gpk.txt", ios::out | ios::binary);

    ifs.seekg(0, ios::end);
    size_t file_size = ifs.tellg();
    ifs.seekg(0, ios::beg);

    char *utf8_data = new char[file_size + 1];
    ifs.read(utf8_data, file_size);
    utf8_data[file_size] = '\0';
    ifs.close();

    cout << "sizeof data = " << file_size << endl;
    cout << utf8_data << endl;


    string buf = str_utf8_to_gpk(utf8_data);

    ofs << buf;

    ifs.close();
    ofs.close();
    delete[] utf8_data;

    return 0;
}